package com.hq.fxh.No0_ChengQu.Adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hq.fxh.R;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/8/14
 * @Email xlwenhao1858@sina.com
 */


public class Adapter_ShareMenu extends BaseAdapter {
    int[] icons;
    String[] names;
    Activity context;

    public Adapter_ShareMenu(int[] icons, String[] names, Activity context) {
        this.icons = icons;
        this.names = names;
        this.context = context;
    }

    @Override
    public int getCount() {
        return 6;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder viewHolder = null;
        if (view == null || !(view.getTag() instanceof ViewHolder)) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_share, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.imgTitle.setImageResource(icons[i]);
        viewHolder.txtTitle.setText(names[i]);
        return view;
    }

    class ViewHolder {
        protected ImageView imgTitle;
        protected TextView txtTitle;

        ViewHolder(View rootView) {
            initView(rootView);
        }

        private void initView(View rootView) {
            imgTitle = (ImageView) rootView.findViewById(R.id.img_share_title);
            txtTitle = (TextView) rootView.findViewById(R.id.txt_share_title);


        }
    }
}
